package sqldbManagement.dbstudents;

import java.awt.font.NumericShaper.Range;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ResourceBundle;

import javax.sound.sampled.ReverbType;

import com.mysql.cj.protocol.Resultset;
import com.mysql.cj.xdevapi.Statement;


public final class JdbcUtil {
	public JdbcUtil() {}
	
	static ResourceBundle rb = ResourceBundle.getBundle("sqldbManagement.dbstudents.jdbc");
	static String url = rb.getString("url");
	static String driver = rb.getString("driver");
	static String user = rb.getString("user");
	static String pass = rb.getString("pass");
	
	static {
		try {
			Class.forName(driver);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	static Connection getConnection() throws SQLException {
		return DriverManager.getConnection(url,user,pass);
	}
	public static void close(Connection conn,PreparedStatement ps) {
		close(conn,ps);
	}
	public static void close1(Connection conn,PreparedStatement ps,ResultSet rs) {
		try {
			if(conn!=null) {
				conn.close();
				conn=null;
			}
			if(ps!=null) {
				((Connection) ps).close();
				ps=null;
			}
			if(rs!=null) {
				((Connection) rs).close();
				rs=null;
			}
		} catch (SQLException e) {
			// TODO: handle exception
		}
	}
	public static void main(String[] args) throws SQLException {
		Connection conn = JdbcUtil.getConnection();
		System.out.println(conn);
		conn.createStatement();
		conn.prepareStatement("");
		
	}
}
